<?php

abstract class AbstractRecipientDeterminationRule implements WorkflowNodeBindableInterface
{
  
  /**
   * @var $options
   */
  protected $options = array();

  public function __construct (array $options = array())
  {
    $this->options = $options;
    
    $this->configure();
  }

  protected function configure ()
  {
  
  }

  /**
   * @param string $name
   * @param mixed $value
   */
  public function setOption ($name, $value)
  {
    $this->options[$name] = $value;
  }

  /**
   * @param string $name
   * @param mixed $default
   * @return mixed
   */
  public function getOption ($name, $default = null)
  {
    if ($this->hasOption($name))
    {
      return $this->options[$name];
    }
    else
    {
      return $default;
    }
  }

  /**
   * @param string $name
   * @return bool
   */
  public function hasOption ($name)
  {
    return isset($this->options[$name]);
  }
  
  abstract public function calculate(wfWorkflowWorkItem $item);

  public function bindToNode (AbstractRunTimeWorkflowNode $node)
  {
    $node->setRecipient($this);
  }
}